package com.example.news.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.news.LoginAvtivity;
import com.example.news.MainActivity;
import com.example.news.R;

public class Fragment_three extends Fragment implements View.OnClickListener {
    TextView top,denglu,shezhi;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_three,container,false);
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        top=getActivity().findViewById(R.id.tv_top);
        denglu=getActivity().findViewById(R.id.tv_denglu);
        shezhi=getActivity().findViewById(R.id.shezhi);
        top.setOnClickListener(this);
        denglu.setOnClickListener(this);
        shezhi.setOnClickListener(this);
        String name=((MainActivity)getActivity()).aa();
        if (name!=null){
            top.setText("用户:"+name);
            denglu.setVisibility(View.GONE);
            top.setOnClickListener(null);
        }
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.wangjimiam:
                break;
            case R.id.tv_top:
                startActivity(new Intent(getActivity(), LoginAvtivity.class));
                break;
            case R.id.tv_denglu:
                startActivity(new Intent(getActivity(), LoginAvtivity.class));
                break;
            case R.id.shezhi:
                top.setText("登陆后现金红包天天领");
                denglu.setVisibility(View.VISIBLE);
                top.setOnClickListener(this);
                break;
        }

    }
}
